<span style='float:left'>
	<h2>Please give your feedback on the finished task: <?php echo $this->task['id']?></h2>
</span>
<span style='float:right;'>
	Team :<?php echo $this->formSelect('team_id', $this->scorelist['team_id'], array('id'=>'team_id','onchange'=>'teamChange(this);'), $this->teams) ?>
</span>

<table class="taskdetail" style='clear:both'>
<tr><td class="item">Title : </td><td><?php echo $this->task['title']?></td></tr>
<tr><td class="item">Property : </td><td><?php echo $this->task['property']?></td></tr>
<tr><td class="item">Requester : </td><td><?php echo $this->task['requester']?></td></tr>
<tr><td class="item">PM : </td><td><?php echo $this->task['manager']?></td></tr>
<tr><td class="item">Assign To : </td><td><?php echo $this->task['developer']?></td></tr>
</table>
<table>
	<tr>
		<td><span class="left"><b>Submit Your Mark <?php echo ($this->scorelist) ? '<font color="red">(Marked)</font>' : '' ?></b></span></td>
	</tr>
	<tr>
		<td>
		<input type="hidden" id="efficiency" name="efficiency" />
		<input type="hidden" id="response" name="response" />
		<input type="hidden" id="quality" name="quality" />
		<input type="hidden" id="responsibility" name="responsibility" />
		<input type="hidden" id="aggressive" name="aggressive" />
		<input type="hidden" id="teamwork" name="teamwork" />
		<div class="marktasktable">
			<table>
				<tr>
					<td id="upd1" style="color:blue;font-weight:bold"></td>
				</tr>
				<tr>
					<td style="background:#ccc"><div id="area1" class="area"><div id="knob1" class="knob" title="toggle me"></div></div></td>
				</tr>
				<tr>
					<td id="upd2" style="color:blue;font-weight:bold"></td>
				</tr>
				<tr>
					<td style="background:#ccc"><div id="area2" class="area"><div id="knob2" class="knob" title="toggle me"></div></div></td>
				</tr>
				<tr>
					<td id="upd3" style="color:blue;font-weight:bold"></td>
				</tr>
				<tr>
					<td style="background:#ccc"><div id="area3" class="area"><div id="knob3" class="knob" title="toggle me"></div></div></td>
				</tr>
				<tr>
					<td id="upd4" style="color:blue;font-weight:bold"></td>
				</tr>
				<tr>
					<td style="background:#ccc"><div id="area4" class="area"><div id="knob4" class="knob" title="toggle me"></div></div></td>
				</tr>
				<tr>
					<td id="upd5" style="color:blue;font-weight:bold"></td>
				</tr>
				<tr>
					<td style="background:#ccc"><div id="area5" class="area"><div id="knob5" class="knob" title="toggle me"></div></div></td>
				</tr>
				<tr>
					<td id="upd6" style="color:blue;font-weight:bold"></td>
				</tr>
				<tr>
					<td style="background:#ccc"><div id="area6" class="area"><div id="knob6" class="knob" title="toggle me"></div></div></td>
				</tr>
			</table>
		</div>
		</td>
	</tr>
	<tr>
		<td colspan="3">
			<input type="button" id="savebtn" value="Submit" class="but" onclick="javascript:sendMark();" />
			<input type="button" id="closebtn" value="Close" class="but" onclick="javascript:PopBox.close();" />
		</td>
	</tr>
</table>

<script type="text/javascript">
function refreshSlider(efficiency, response, quality, responsibility, aggressive, teamwork){
	new Slider($('area1'), $('knob1'), {
		steps: 5,
		onChange: function(step){
			$('efficiency').value = step;
			$('upd1').setHTML('Efficiency Score : '+step);
		}
	}).set(efficiency);
	new Slider($('area2'), $('knob2'), {
		steps: 5,
		onChange: function(step){
			$('response').value = step;
			$('upd2').setHTML('Response Score : '+step);
		}
	}).set(response);
	new Slider($('area3'), $('knob3'), {
		steps: 5,
		onChange: function(step){
			$('quality').value = step;
			$('upd3').setHTML('Quality Score : '+step);
		}
	}).set(quality);
	new Slider($('area4'), $('knob4'), {
		steps: 5,
		onChange: function(step){
			$('responsibility').value = step;
			$('upd4').setHTML('Responsibility Score : '+step);
		}
	}).set(responsibility);
	new Slider($('area5'), $('knob5'), {
		steps: 5,
		onChange: function(step){
			$('aggressive').value = step;
			$('upd5').setHTML('Aggressive Score : '+step);
		}
	}).set(aggressive);
	new Slider($('area6'), $('knob6'), {
		steps: 5,
		onChange: function(step){
			$('teamwork').value = step;
			$('upd6').setHTML('Teamwork Score : '+step);
		}
	}).set(teamwork);
}
setTimeout('refreshSlider(<?php echo isset($this->scorelist['efficiency']) ? $this->scorelist['efficiency'] : 0 ?>,<?php echo isset($this->scorelist['response']) ? $this->scorelist['response'] : 0 ?>,<?php echo isset($this->scorelist['quality']) ? $this->scorelist['quality'] : 0 ?>,<?php echo isset($this->scorelist['responsibility']) ? $this->scorelist['responsibility'] : 0 ?>,<?php echo isset($this->scorelist['aggressive']) ? $this->scorelist['aggressive'] : 0 ?>,<?php echo isset($this->scorelist['teamwork']) ? $this->scorelist['teamwork'] : 0 ?>)', 100);
var request_uri = '<?php echo $this->mark_url;?>?t='+(new Date()).getTime();
var sendMark = function () {
	$('loadingbox').setStyle('display', 'block');
	new Ajax(request_uri, {
		method: 'get',
		data: Object.toQueryString({
			efficiency: $('efficiency').value,
			response: $('response').value,
			quality: $('quality').value,
			responsibility: $('responsibility').value,
			aggressive: $('aggressive').value,
			teamwork: $('teamwork').value,
			task_id: <?php echo $this->task['id']?>,
			team_id: $('team_id').value
		}),
		onComplete: function(){
			$('loadingbox').setStyle('display', 'none');
			if ('success' != this.response.text) {
				alert('Your message sent failure!');
			} else {
				alert('Mark successed!');				
			}
		}
	}).request();
}
var teamChange = function(select) {
	$('loadingbox').setStyle('display', 'block');
	new Ajax(request_uri, {
		method: 'get',
		data: Object.toQueryString({
			fn: 'get',
			team_id: select.value,
			task_id: <?php echo $this->task['id']?>
		}),
		onComplete: function(){
			$('loadingbox').setStyle('display', 'none');
			if ('failure' == this.response.text) {
				alert('Your message sent failure!');
			} else {
				eval("var sorce="+this.response.text);
				if (sorce) {
					refreshSlider(parseInt(sorce.efficiency), 
								  parseInt(sorce.response), 
								  parseInt(sorce.quality),
								  parseInt(sorce.responsibility),
								  parseInt(sorce.aggressive),
								  parseInt(sorce.teamwork));
				}
			}
		}
	}).request();
}
</script>